package com.seaside.park.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.seaside.park.bean.CarReception;
import com.seaside.park.bean.CarReceptionLocker;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface CarReceptionMapper extends BaseMapper<CarReception> {
    @Select("SELECT cr.*, pl.locker_number, pl.locker_photo " +
            "FROM car_reception cr " +
            "LEFT JOIN park_locker pl ON cr.id = pl.car_reception_id " +
            "${ew.customSqlSegment}")
    IPage<CarReceptionLocker> selectPageWithParkLocker(Page<CarReceptionLocker> page, @Param(Constants.WRAPPER) QueryWrapper<CarReception> queryWrapper);

    @Update("UPDATE car_reception SET target_position = #{targetPosition}, car_status = #{carStatus}, updated_at = #{updatedAt}, target_time = #{targetTime} WHERE id = #{id}")
    void forceUpdateById(CarReception carReception);
}
